import request from "@/utils/request";

// 获取基本的用户列表, 带搜索
export const apiGetUserList = ({page,limit,searchObj})=> {
  return request({
    method:'get',
    url: `/admin/acl/user/${page}/${limit}`,
    params: {username: searchObj}
  })
}

// 添加用户或者修改用户
export const apiSaveAndEditUser = (data)=>{
  if(data.id) {
    return request({
      method:'put',
      url:'/admin/acl/user/update',
      data
    })
  }else {
    return request.post('/admin/acl/user/save', data)
  }
}

// 删除用户
export const apiDeleteUser = (id)=>request.delete(`/admin/acl/user/remove/${id}`)

// 批量删除用户
export const apiSelectDelete = (idList)=>{
  return request({
    method: 'delete',
    url:'/admin/acl/user/batchRemove',
    data: idList
  })
}

// 通过用户id获取用户已有的角色信息
export const apiGetUserRoleById =  userId =>request(`/admin/acl/user/toAssign/${userId}`)

// 给用户分配角色   /admin/acl/user/doAssign
export const apiAssignRole = (userId,roleId)=>{

  return request({
    method:'post',
    url:'/admin/acl/user/doAssign',
    params:{
      userId,
      roleId
    }
  })
}


